<?php

namespace Laoha\Core;

use Encore\Admin\Admin;
use Encore\Admin\Extension;

class Core extends Extension
{
    public $name = 'core';

    public $views = __DIR__.'/../resources/views';

    public $assets = __DIR__.'/../resources/assets';


    public static function boot()
    {
        static::registerRoutes();
        Admin::extend('laoha', __CLASS__);
    }

    protected static function registerRoutes()
    {
        parent::routes(function ($router) {
            /* @var \Illuminate\Routing\Router $router */
            $router->resource('laoha/table', 'Laoha\Core\TableController')->names('admin.laoha.table');
			$router->resource('laoha/cate', 'Laoha\Core\CateController')->names('admin.laoha.cate');
			$router->get('laoha/set', 'Laoha\Core\SetController@index');
			$router->post('laoha/set', 'Laoha\Core\SetController@save');
        });
    }

    public static function import()
    {
        parent::createMenu('Table Manager','laoha/table','fa-list-ul');
		parent::createMenu('Cate Manager', 'laoha/cate', 'fa-list');
		parent::createMenu('Config Manager', 'laoha/set', 'fa-toggle-on');
        parent::createPermission('Table Manager', 'laoha.table', 'laoha/table*');
		parent::createPermission('Cate Manager', 'laoha.cate', 'laoha/cate*');
		parent::createPermission('Config Manager', 'laoha.set', 'laoha/set');
    }
}